﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!-- Resource dictionary entries should be defined here. -->
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Colors.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="{x:Type ListViewItem}"
       TargetType="ListViewItem">
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="Padding" Value="3" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground">
            <Setter.Value>
                <SolidColorBrush Color="{StaticResource Application_ListViewItem_Foreground}"/>
            </Setter.Value>
        </Setter>
        <Setter Property="IsTabStop" Value="True" />
        <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=ListViewItemTemplate, TypeInTargetAssembly={x:Type ListViewItem}}}"/>
    </Style>

    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=ListViewItemTemplate, TypeInTargetAssembly={x:Type ListViewItem}}" TargetType="ListViewItem">
        <Grid Background="{TemplateBinding Background}">
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualStateGroup.Transitions>
                        <VisualTransition From="Normal" GeneratedDuration="0:0:0.4" To="MouseOver"/>
                        <VisualTransition From="MouseOver" GeneratedDuration="0:0:0.4" To="Normal"/>
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="Normal"/>
                    <VisualState x:Name="MouseOver">
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="bg">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_ListViewItem_Background_Move}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Disabled">
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_ListViewItem_Foreground_Disabled}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="SelectionStates">
                    <VisualStateGroup.Transitions>
                        <VisualTransition GeneratedDuration="0:0:0.2" To="Selected"/>
                        <VisualTransition From="Selected" GeneratedDuration="0:0:0.2"/>
                        <VisualTransition From="Selected" GeneratedDuration="0:0:0.3" To="SelectedUnfocused"/>
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="Unselected"/>
                    <VisualState x:Name="Selected">
                        <Storyboard>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="SelectionFill">
                                <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="SelectionBorder">
                                <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="SelectedUnfocused">
                        <Storyboard>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="SelectionBorder">
                                <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="FocusStates">
                    <VisualState x:Name="Unfocused"/>
                    <VisualState x:Name="Focused"/>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Rectangle x:Name="bg" Opacity="1" IsHitTestVisible="False" RadiusX="1" RadiusY="1">
                <Rectangle.Fill>
                    <SolidColorBrush Color="{StaticResource Application_ListViewItem_Background}"/>
                </Rectangle.Fill>
            </Rectangle>
            <Rectangle x:Name="SelectionFill" Grid.Column="0" Grid.ColumnSpan="1" RadiusX="0" Opacity="0" Height="Auto" Margin="0" VerticalAlignment="Stretch">
                <Rectangle.Fill>
                    <SolidColorBrush Color="{StaticResource Application_ListViewItem_Background_Selection}" />
                </Rectangle.Fill>
            </Rectangle>
            <GridViewRowPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
            <Rectangle x:Name="SelectionBorder" Grid.Column="0" Grid.ColumnSpan="1" Opacity="0" StrokeThickness="1" IsHitTestVisible="False" Height="Auto" Margin="0" VerticalAlignment="Stretch">
                <Rectangle.Stroke>
                    <SolidColorBrush Color="{StaticResource Application_ListViewItem_BorderBrush_Selection}" />
                </Rectangle.Stroke>
            </Rectangle>
        </Grid>
    </ControlTemplate>
</ResourceDictionary>